Uec3.ShowMarketWindow = Ext.extend(Ext.Window, {
	initPanel : function() {

		this.advancedQueryPanel = this.createAdvancedQueryPanel();
		this.openWindow = this.createOpenWindow();

		this.record = this.createRecord();
		this.colName = this.createColName();
		this.store = this.createStore();
		this.grid = this.createGrid();

		this.joinPanel = this.createJoinPanel();

		this.add(this.joinPanel);
		this.doLayout();
		this.show();
		this.creator.app.getDesktop().addAutoRun(this.getId());
		this.store.load();
	},
	createJoinPanel : function() {
		return new Ext.FormPanel({
					items : [{
						height : 60,
						layout : 'hbox',
						border : false,
						layoutConfig : {
							padding : '5',
							align : 'middle'
						},
						items : [{
									xtype : 'label',
									text : '浏览市场信息',
									style : 'color:#000;font-size:26px;background:#fff'
								}, {
									xtype : 'spacer',
									flex : 1
								}, {
									xtype : 'button',
									text : '高级查找',
									handler : this.queryByComplex
											.createDelegate(this)
								}]
					}, this.grid]
				});
	},

	queryByComplex : function() {
		this.advancedQueryPanel.getForm().reset();
		this.openWindow.show();
	},
	createAdvancedQueryPanel : function() {
		return new Ext.form.FormPanel({
					labelSeparator : "：",
					frame : true,
					border : false,
					items : [{
								xtype : 'textfield',
								width : 200,
								fieldLabel : '市场名称',
								name : 'name'
							}, {
								xtype : 'textfield',
								width : 200,
								fieldLabel : '市场类型(0二级;1一级;2保险)',
								name : 'marketType'
							}, {
								xtype : 'textfield',
								width : 200,
								fieldLabel : '说明',
								name : 'description'
							}],
					buttons : [{
								text : '查找',
								handler : this.searchResultByCondition.createDelegate(this)
							}, {
								text : '关闭',
								handler : function() {
									this.openWindow.hide();
								}.createDelegate(this)
							}]

				});
	},
	searchResultByCondition : function() {
		var form_values = this.advancedQueryPanel.getForm().getValues();
	
		for (var j in form_values) {
			form_values[j] = castNoSelToNULL(form_values[j]);
		}
			
		form_values = Ext.util.JSON.encode(form_values);
		if(form_values) {
			this.store.baseParams = {'queryParam' : form_values};
		} else {
			this.store.baseParams = {};
		}
		this.store.load();
		this.openWindow.hide();
	},
	createOpenWindow : function() {
		return new Ext.Window({
					title : '高级查找',
					layout : 'fit',
					width : 380,
					closeAction : 'hide',
					height : 330,
					resizable : true,
					shadow : true,
					modal : true,
					closable : true,
					bodyStyle : 'padding:5 5 5 5',
					animCollapse : true,
					items : [this.advancedQueryPanel]
				});
	},
	createRecord : function() {
		return Ext.data.Record.create([{
					name : 'id'
				}, {
					name : 'name'
				}, {
					name : 'marketType'
				}, {
					name : 'description'
				}]);
	},
	createColName : function() {

		return new Ext.grid.ColumnModel([
				{
					header : '市场名称',
					dataIndex : 'name'
				}, {
					header : '市场类型',
					dataIndex : 'marketType'
				}, {
					header : '说明',
					dataIndex : 'description'
				}]);
	},
	createStore : function() {
		return new Ext.data.JsonStore({
					url : RES_PATH + '/market/listMarket.do',
					baseParams : {
//						orderId : this.orderId
					},
					mode : "local",
					totalProperty : "totalProperty",
					root : "root",
					idProperty : "id",
					pruneModifiedRecords : true,
					fields : this.record
				});
	},
	createGrid : function() {
		return new Ext.grid.GridPanel({
					title : '数据明细',
					cm : this.colName,
					store : this.store,
					iconCls : 'icon-grid',
					loadMask : {
						msg : '数据加载中...'
					},
					viewConfig : {
						forceFit : true
					},
					height : 380,
					bbar : new Ext.PagingToolbar({
								pageSize : Uec3PageSize,
								store : this.store,
								displayInfo : true,
								displayMsg : '第 {0} - {1} 条  共 {2} 条',
								emptyMsg : "没有记录"

							})
				});
	}

});


Uec3.ShowMarketWindowCreator = Ext.extend(Ext.app.Module, {
			id : 'showMarketWindowCreator',
			type : 'common/notepad',

			createWindow : function() {
				var desktop = this.app.getDesktop();
				var win = desktop.getWindow('showMarketWindow');
				if (win) {
					win.toFront();
				} else {
					win = desktop.createWindow({
								id : 'showMarketWindow',
								title : '浏览市场信息',
								width : 1010,
								height : 500,
								iconCls : 'acc-icon',
								animCollapse : true,
								constrainHeader : true,
								maximizable : true,
								taskbuttonTooltip : "浏览市场信息",
								layout : "fit",
								items : []
							}, Uec3.ShowMarketWindow);

					win.creator = this;
					win.initPanel();
				}
			}
		});